﻿using System.Collections.Generic;
using WebAPI.Dao;
using WebAPI.Entities;

namespace WebAPI.Services;

public class TagService
{
    private TagMapper _tagMapper = new TagMapper();
    private TimeTransferUtils _transferUtils = new TimeTransferUtils();
    private IdGenerate _idGenerate = new IdGenerate();
    
    public List<Tag> GetAllTags()
    {
        List<Tag> tags = _tagMapper.SelectAll();
        
        return tags;
    }

    public bool AddTag(Tag tag)
    {
        tag.Id = _idGenerate.GetId();
        
        int flag = _tagMapper.Insert(tag);
        
        return flag > 0;
    }
    
    public bool UpdateTag(Tag tag)
    {
        int flag = _tagMapper.Update(tag);
        
        return flag > 0;
    }
    
    public bool DeleteTag(Tag tag)
    {
        int flag = _tagMapper.Delete(tag);
        
        return flag > 0;
    }
}